<link href="<?=url()?>templates/css/lienhe.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="<?=url?>templates/js/ajaxupload.js"></script>
<!--<link href="<?=url()?>templates/css/ui/colorbox.css" type="text/css" rel="stylesheet" />
<script src="<?=url().'templates/js/ui/jquery.colorbox.min.js'?>"></script>
<script src="<?=url().'templates/js/filelib.js'?>"></script>-->
<style type="text/css">
.cont_right div .btn {
	background: none repeat scroll 0 0 #fff423;
	border-radius: 5px;
	color: #000000;
	font-weight: bold;
	margin-top: 10px;
	margin-right: 60px;
	padding: 5px 10px;
	width: 90px;
	height: 20px;
}
.btn a {
	font-weight: bold;
	color: #222;
}
.btn a:hover {
	font-weight: bold;
	color: #1c7fc3;
}
</style>
<div class="lienhe">
    <div class="cont_left">
        <div class="cont_title">Upload mẫu</div>
        <form id="frmcontacts" name="frmcontacts" method="post" action="<?=site?>upload/action" enctype="multipart/form-data">
        	<input type="hidden" id="lb_image" name="lb_image" value="" />
            <div class="contacts">
                <p><?=lang('text_lien_he')?></p>
                <ul>
                    <li class="left"><?=lang('ho_ten')?></li>
                    <li class="right"><input type="text" size="40" id="cusname" name="cusname" class="lhe"></li>
                </ul>
                <ul>
                    <li class="left">Email</li>
                    <li class="right"><input type="text" size="40" id="cusmail" name="cusmail" class="lhe"></li>
                </ul>
                <ul>
                    <li class="left">Địa chỉ</li>
                    <li class="right"><input type="text" size="40" id="address" name="address" class="lhe"></li>
                </ul>
                <ul>
                    <li class="left">Phone</li>
                    <li class="right"><input type="text" size="40" id="phone" name="phone" class="lhe"></li>
                </ul>
                <ul>
                    <li class="left">
                        <?=lang('noi_dung')?>
                        :</li>
                    <li class="right"><textarea rows="10" style="width:250" cols="35" id="noidung" name="noidung"></textarea></li>
                </ul>
                <ul>
                    <li><!--(*)Bắt buộc phải điền thông tin--> </li>
                    <li class="right" style="text-align:left; padding-left:112px; padding-top: 0"><input type="submit" value="<?=lang('btn_send')?>" id="btnlienhe" class="btn" name="btnupload" style="margin: 10px 15px; width:70px; height:30px">
                    </li>
                </ul>
            </div>
        </form>
    </div>
    <div class="cont_right">
        <div class="cont_title" style="padding-left:0;"><?=lang('hinh_anh')?>
            
        </div>
        <p style="margin-top:15px;"><?=lang('text_image');?></p>
        <div style="padding:10px 0;"> 
        	<span class="btn" id="btUpload"><a href="#"><?=lang('upload_mau')?></a></span> 
        	<span class="btn"><a href="<?=site?>chon-mau.html"><?=lang('chon_mau_in')?></a></span> 
        </div>
        <div id="imgupload"><img class="img_temp" src="<?=url?>templates/images/map.gif"></div>
    </div>
    <div class="clear"></div>
</div>
<script language="javascript">
$(document).ready(function(){
	var flag = true ;
	$("#frmcontacts").validate({
		rules: {
			cusname : {required:true},
			cusmail: { required:true,email:true},
			phone: { required:true,number:true},
			noidung: { required:true}
		},                
		messages: {
			cusname: "Vui lòng nhập tên liên hệ.",
			cusmail: {required:"Vui lòng nhập email.",email:"Vui lòng nhập đúng email"},
			phone: {required:"Vui lòng nhập số điện thoại.", number:"Vui lòng chỉ nhập số"},
			noidung: "Vui lòng điền thông tin cần gởi."
		},
		/*submitHandler: function(form) {
			dataString = $("#frmcontacts").serialize();
			if(flag){
				flag = false;
				$.ajax({
					type: "POST",
					url: "<?=base_url()?>register/doadd",
					data: dataString,
					success: function(data) {
						if(data == 1 )
						{
							flag = true;
							window.location = site+'register/success' ;                   
						}
						else
						{
							window.location = site+'login/form' ;  
						}
					}
				});
			}
		}*/
	});

	// add method validate phone
	/*$.validator.addMethod("validate_phone", function (str) {
		var reg = /^(84|0)[\d]{8,11}$/;
		//str=$('#phone').val();
		if (reg.test(str) == false) {
			return false;
		} else {
			return true;
		}
	});*/

});
</script> 
<script language="javascript">
$(function($){
	var btnUpload = $('#btUpload');
	new AjaxUpload(btnUpload,{
		action: site+'upload/picture',
		name: 'uploadfile',
		responseType:'json',
		onSubmit: function(file, ext){
			 if (! (ext && /^(jpg|png|jpeg|gif|)$/.test(ext))){ 
				return false;
			}
		},
		onComplete: function(file, res){ trit(res);
			if(res.code==1)
			{
				$("#imgupload").html('<img class="crop_me" src="'+url+'uploads/temp/'+res.filename+'" width="380px" />');
				$("#lb_image").val(res.filename);
			}else{
				jAlert(res.message,'THÔNG BÁO');
			}
		}
	});
});
</script>
